﻿using System;
using System.Windows.Data;
using System.Windows.Controls;
using System.Windows;

namespace BizControl.Presentation.StickyNotesModule.Converters
{
  public class IndexToMarginValueConverter : IValueConverter
  {
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      ListBoxItem item = (ListBoxItem)value;
      ListBox listBox = (ListBox)ItemsControl.ItemsControlFromItemContainer(item);
      int itemIndex = listBox.ItemContainerGenerator.IndexFromContainer(item);
      if (itemIndex == 0)
        return new Thickness(0, 10, 20, 0);
      else
        return new Thickness(0, 3, 20, 0);
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
      return null;
    }

    #endregion
  }
}
